package ArrayListTest;

import java.util.ArrayList;

public class Test4 {
    public static void main(String[] args) {
        ArrayList<User> list3 = new ArrayList<>();

        User a1 = new User("001","周星辰","123456");
        User a2 = new User("002","胡峰","112233");
        User a3 = new User("003","万宝利","200309");
        a1.getId();
        a2.getId();
        a3.getId();
        list3.add(a1);
        list3.add(a2);
        list3.add(a3);

        int index1 = qwe(list3 , "002");
        System.out.println(index1);
        int index2= qwe(list3 , "004");
        System.out.println(index2);

    }
    public static int qwe(ArrayList<User> list3 , String id){
        for(int i = 0 ;i<list3.size();i++){
            User u = list3.get(i);
            String uid = u.getId();
            if(id.equals(uid)){
                return i;
            }
        }
        return -1;
    }
}
